﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="Reconciliation.Web.Users_Control.Filters" CodeFile="Filters.ascx.cs" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

    <script type="text/javascript">
           
            function showCalendar()
            {
                document.getElementById("divCal1").style.display="block";
            } 
            
            function closeCalendar()
            {
                document.getElementById("divCal1").style.display="none";
            }  
            
            function selectdDates()
            {   
                var calendar = $find("<%= RadCalendar1.ClientID %>");
                
                var selectedDatesArray = calendar.get_selectedDates();  
                var strDateSelected="";
                var strStartDate="1/1/1900";
                var strEndDate="1/1/2100";
                
                var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
                if (selectedDatesArray.length>0)
                {
                    // date format YYYY/MM/DD
                    var strDatesMin = selectedDatesArray[0].toString();
                    var arrMinDates = strDatesMin.split(","); 
                    var minmonth=arrMinDates[1];
                    strDateSelected = arrMinDates[2]+" "+monthname[minmonth-1];
                    strStartDate = arrMinDates[1]+"/"+arrMinDates[2]+"/"+arrMinDates[0];
                    
                    var strDatesMax = selectedDatesArray[selectedDatesArray.length - 1].toString();
                    var arrMaxDates = strDatesMax.split(",");
                    var maxmonth=arrMaxDates[1];
                    strDateSelected = strDateSelected +" - "+ arrMaxDates[2]+" "+monthname[maxmonth-1];
                    strEndDate = arrMaxDates[1]+"/"+arrMaxDates[2]+"/"+arrMaxDates[0];
                    
                    calendar.unselectDates(selectedDatesArray);
                }
                
                document.getElementById("<%= hddDate1.ClientID %>").value = strStartDate;
                document.getElementById("<%= hddDate2.ClientID %>").value = strEndDate;
                                
                document.getElementById("<%= txtDateFromTo.ClientID %>").value = strDateSelected;
                document.getElementById("<%= hddSelectedDate.ClientID %>").value = strDateSelected;
                closeCalendar();
                
                return true;
                /*
                for (k=0; k<selectedDatesArray.length; k++)
                {
                    var strDates = selectedDatesArray[k].toString();
                    var arrDates = strDates.split(",");
                    
                    
                    alert(arrDates.length)
                    alert(selectedDatesArray[k]);
                } 
                */           
            }
            
            function showFilter(lnk)
            {
                var pnlblock=document.getElementById("pnlFilter");
                if (pnlblock.style.display=="none")
                {
                    pnlblock.style.display="block";
                    lnk.innerHTML = "<%=Resources.Lang.Close.ToString()%>";
                }
                else
                {
                    pnlblock.style.display="none";
                    lnk.innerHTML = "<%=Resources.Lang.Filter.ToString()%>";
                }
                return false;
            }
    </script>

</telerik:RadCodeBlock>

<table width="100%" style="height: 50px;">
    <tr>
        <td style="width: 150px; color: Black; font-size: 14px; font-weight: bold;">
            <asp:Label runat="server" ID="lblTitle" Text="<%$ Resources:Lang, Reconciliation_Status%>" />
        </td>
        <td style="width: 160px;">
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td>
                        <asp:TextBox runat="server" ID="txtDateFromTo" ReadOnly="true" />
                        <asp:HiddenField runat="server" ID="hddSelectedDate" Value="" />                        
                        <asp:HiddenField runat="server" ID="hddDate1" Value="1/1/1900" />
                        <asp:HiddenField runat="server" ID="hddDate2" Value="1/1/2100" />
                    </td>
                    <td style="padding: 3px;">
                        <a href="javascript:showCalendar()">
                            <img src="images/icons/cal.jpg" border="0" /></a>
                    </td>
                </tr>
            </table>
            <div id="divCal1" style="position: absolute; display: none;">
                <div style="height: 15px; padding: 2px; background-color: #EAEAEA; width: auto; border-bottom: 0px;
                    border: solid 1px #999999;">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td width="85%">
                            </td>
                            <td>
                                <asp:ImageButton OnClientClick="return selectdDates();" OnClick="imgApply_Click"
                                    Height="13" Width="12" runat="server" ID="imgApply" ImageUrl="~/images/icons/apply.jpg"
                                    BorderWidth="0" />
                            </td>
                            <td>
                                <a href="javascript:closeCalendar()">
                                    <img src="images/icons/close.jpg" height="13" width="12" /></a>
                            </td>
                        </tr>
                    </table>
                </div>
                <telerik:RadCalendar runat="server" ID="RadCalendar1" EnableMultiSelect="true" />
            </div>
        </td>
        <td align="right">
            <asp:Panel runat="server" ID="pnlStausBlock" Visible="false">
                <table cellpadding="0" cellspacing="0" width="100%" border="0">
                    <tr>
                        <td align="left">
                            <asp:LinkButton runat="server" Visible='<%#Context.User.IsInRole("All")%>' ID="lnkFilter"
                                Text="<%$ Resources:Lang, Filter%>" Font-Bold="true" ForeColor="Blue" OnClientClick="return showFilter(this)" />
                        </td>
                        <td align="right">
                            <telerik:RadAjaxLoadingPanel Width="150" HorizontalAlign="Right" Skin="Vista" runat="server"
                                ID="RadAjaxLoadingPanel2" />
                            <div id="pnlFilter" style="display:none;">
                                <table>
                                    <tr>
                                        <td align="left">
                                            <asp:Label runat="server" ID="Label1" Font-Bold="true" Text="<%$ Resources:Lang, CCP%>" />
                                        </td>
                                        <td align="left">
                                            <asp:Label runat="server" ID="Label3" Font-Bold="true" Text="<%$ Resources:Lang, Bank%>" />
                                        </td>
                                        <td align="left">
                                            <asp:Label runat="server" ID="Label4" Font-Bold="true" Text="<%$ Resources:Lang, Amount%>" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="left">
                                            <asp:DropDownList  runat="server" AutoPostBack="true"
                                                ID="ddCCP" OnSelectedIndexChanged="ddCCP_SelectedIndexChanged">
                                            </asp:DropDownList>
                                        </td>
                                        <td align="left">
                                            <asp:DropDownList runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddBank_Status_SelectedIndexChanged"
                                                ID="ddBank_Status">
                                            </asp:DropDownList>
                                        </td>
                                        <td>
                                            <asp:DropDownList runat="server" AutoPostBack="true" ID="ddAmountFilter" OnSelectedIndexChanged="ddAmountFilter_SelectedIndexChanged">
                                                <asp:ListItem Value="&gt;">&gt;</asp:ListItem>
                                                <asp:ListItem Value="&gt;=">&gt;=</asp:ListItem>
                                                <asp:ListItem Value="&lt;">&lt;</asp:ListItem>
                                                <asp:ListItem Value="&lt;=">&lt;=</asp:ListItem>
                                                <asp:ListItem Value="=">=</asp:ListItem>
                                                <asp:ListItem Value="!=">!=</asp:ListItem>
                                            </asp:DropDownList>
                                            <asp:TextBox runat="server" ID="txtAmount" Width="50"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <asp:Panel runat="server" ID="pnlInvoiceBlock" Visible="true">
                <table>
                    <tr>
                        <td align="left">
                            <asp:Label runat="server" ID="lable1" Text="<%$ Resources:Lang, Type%>" Font-Bold="true" />
                        </td>
                        <td align="left">
                            <asp:Label runat="server" ID="Label5" Text="<%$ Resources:Lang, Bank%>" Font-Bold="true" />
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <asp:DropDownList runat="server" AutoPostBack="true" ID="ddType" OnSelectedIndexChanged="ddType_SelectedIndexChanged">
                                <asp:ListItem Value="Shortage">Shortage</asp:ListItem>
                                <asp:ListItem Value="Full">Full</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td align="left">
                            <asp:DropDownList runat="server" AutoPostBack="true" ID="ddBank_Invoice" OnSelectedIndexChanged="ddBank_Invoice_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
        </td>
    </tr>
</table>
